using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InvestmentIntelligence.DbModel.Models.Mapping
{
    public class TradeMap : EntityTypeConfiguration<Trade>
    {
        public TradeMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            this.Property(t => t.SecurityId)
              .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FundBookEntityId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            // Properties
            // Table & Column Mappings
            this.ToTable("Trade", "TradingData");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Quantity).HasColumnName("Quantity");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.Size).HasColumnName("Size");
            this.Property(t => t.SecurityId).HasColumnName("SecurityId");
            this.Property(t => t.FundBookEntityId).HasColumnName("FundBookEntityId");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.TraderId).HasColumnName("TraderId");
            this.Property(t => t.StrategyId).HasColumnName("StrategyId");
            this.Property(t => t.CurrencyId).HasColumnName("CurrencyId");
            this.Property(t => t.FxRate).HasColumnName("FxRate");
            this.Property(t => t.OriginalId).HasColumnName("OriginalId");
            this.Property(t => t.AdditionalData).HasColumnName("AdditionalData");

            // Relationships
            this.HasRequired(t => t.Security);
            this.HasRequired(t => t.FundBookEntity);
        }
    }
}
